package cn.just.entity;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author wujiaming
 */
public class Article {
    /**
     * 主键
     */
    private Integer oId;

    /**
     * 标题
     */
    private String title;

    /**
     * 摘要(abstract)  大文本text
     */
    private String abs;

    /**
     * 用户名 article表中没有这个字段  需要查询user表
     */
    private String userName;

    /**
     * 评论量
     */
    private Integer commentCount;

    /**
     * 浏览量
     */
    private Integer viewCount;

    /**
     * 是否置顶 0不置顶 1表示置顶
     */
    private Integer putTop;

    /**
     * 创建时间戳 毫秒值
     */
    private Long created;

    /**
     * 跟新时间戳
     */
    private Long updated;

    /**
     * 图片名称
     */
    private String imgName;

    /**
     * 对饮标签集合
     */
    private List<Tag> tags;

    /**
     * 正文
     */
    private String content;

    /**
     * 修改时间字符串
     */
    private String updateStr;

    /**
     * 创建时间字符串 yyyy-MM-dd HH:mm
     */
    private String createdSrc;

    /**
     * 用户作者id
     */
    private Integer authorId;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getUpdateStr() {
        Date date = new Date(updated);
        DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH点mm分");
        return df.format(date);
    }

    public void setUpdateStr(String updateStr) {
        this.updateStr = updateStr;
    }

    public String getCreatedSrc(){
        //根据属性createdSrc
        Date date = new Date(created);
        //利用DateFormat日期格式化类 把日期转化为字符串
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return dateFormat.format(date);
    }

    public void setCreatedSrc(String createdSrc){
        this.createdSrc = createdSrc;
    }

    public Article() {
    }

    public Article(Integer oId, String title, String abs, String userName,
                   Integer commentCount, Integer viewCount, Integer putTop, Long created, Long updated, String imgName) {
        this.oId = oId;
        this.title = title;
        this.abs = abs;
        this.userName = userName;
        this.commentCount = commentCount;
        this.viewCount = viewCount;
        this.putTop = putTop;
        this.created = created;
        this.updated = updated;
        this.imgName = imgName;
    }

    public Integer getoId() {
        return oId;
    }

    public void setoId(Integer oId) {
        this.oId = oId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAbs() {
        return abs;
    }

    public void setAbs(String abs) {
        this.abs = abs;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getCommentCount() {
        return commentCount;
    }

    public void setCommentCount(Integer commentCount) {
        this.commentCount = commentCount;
    }

    public Integer getViewCount() {
        return viewCount;
    }

    public void setViewCount(Integer viewCount) {
        this.viewCount = viewCount;
    }

    public Integer getPutTop() {
        return putTop;
    }

    public void setPutTop(Integer putTop) {
        this.putTop = putTop;
    }

    public Long getCreated() {
        return created;
    }

    public void setCreated(Long created) {
        this.created = created;
    }

    public Long getUpdated() {
        return updated;
    }

    public void setUpdated(Long updated) {
        this.updated = updated;
    }

    public String getImgName() {
        return imgName;
    }

    public void setImgName(String imgName) {
        this.imgName = imgName;
    }

    public List<Tag> getTags() {
        return tags;
    }

    public void setTags(List<Tag> tags) {
        this.tags = tags;
    }

    public Integer getAuthorId() {
        return authorId;
    }

    public void setAuthorId(Integer authorId) {
        this.authorId = authorId;
    }
}
